 var name = 'luojianming';
    var age = 18;
    var obj = {
        name: 'luo',
        age: 20
    }

    function template(str, obj) {
        console.log(str);
        var res = str.replace(/\$\{(\w+)\}/g, function (match, prop, index, str) {
            // return eval(prop)
            return obj[prop]
        })
        console.log(res);
    }
    var str = 'My name is ${name}, ${age} years old'
    template(str, obj)